//数组实现建树
#include<iostream>
#include<cstring>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<map>
#include<set>
#include<vector>
#include<queue>
#include<cstdlib>//rand()
#define rep(i,a,b) for(register int i = (a);i <= (b);++i)
#define per(i,a,b) for(register int i = (a);i >= (b);--i)
typedef long long ll;
typedef unsigned long long ull;
using std::string;using std::cin;using std::cout;
using std::queue;

int n,c[1000005],tot,len;
string s;

struct node{
    int fail_tag,end_tag,to[30];
}AC[1000005];


inline void build(){
    len = s.length();
    rep(i,1,len) c[i] = s[i-1] - 'a' + 1;
    int now = 0;
    rep(i,1,len){
        if(AC[now].to[ c[i] ] == 0) AC[now].to[ c[i] ] = ++tot;
        now = AC[now].to[ c[i] ];
    }
    ++AC[now].end_tag;
    return;
}

inline void get_fail(){
    len = s.length();
    rep(i,1,len) c[i] = s[i-1] - 'a' + 1;
    queue<int> q;
    int now = 0;
    rep(i,1,26){
        AC[ AC[now].to[i] ].fail_tag = 0;
        if(AC[now].to[i] > 0) q.push(AC[now].to[i]);
    }
    while(q.size()){
        now = q.front();q.pop();
        rep(i,1,26){
            if(AC[now].to[i] > 0) AC[ AC[now].to[i] ].fail_tag = AC[ AC[now].fail_tag ].to[i];
            if(AC[now].to[i] > 0) q.push(AC[now].to[i]);
            if(AC[now].to[i] == 0) AC[now].to[i] = AC[ AC[now].fail_tag ].to[i];
        }
    }
    return;
}

inline int query(string str){
    len = str.length();
    rep(i,1,len) c[i] = s[i-1] - 'a' + 1;
    int now = 0 , ans = 0;
    rep(i,1,len){
        now = AC[now].to[c[i]];
        for(int j = now;j && AC[j].end_tag != -1;j = AC[j].fail_tag) ans += AC[j].end_tag , AC[j].end_tag = -1;
    }
    return ans;
}

int main(){
    std::ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    //freopen("in.in", "r", stdin);
    cin >> n;
    rep(i,1,n){
        cin >> s;
        build();
    }
    get_fail();
    cin >> s;
    cout << query(s) << "\n";


    return 0;
}
